"use strict"
app.controller('initCtrl', function($scope, $http,$state) {
	
	/*$http.post(
			'autihority/queryUserPermissions?groupId=' + $("#groupId").val(),
			{}).success(function(result) {
		var datas = result.dataList;
		var hasSystem = false;
		var hasHistory = false;
		for (var i = 0; i < datas.length; i++) {
			if (datas[i].menu_code == "monitor") {
				$("#monitor>a").attr("href", datas[i].menu_url);
				$("#monitor>a").removeAttr("onclick");
			
			} 
			if (datas[i].menu_code == "forecast") {
				$("#forecast>a").attr("href", datas[i].menu_url);
				$("#forecast>a").removeAttr("onclick");
				
			}
			if (datas[i].menu_type == "系统管理" && hasSystem == false) {
				$("#system>a").attr("href", datas[i].menu_url);
				hasSystem = true;
				$("#system>a").removeAttr("onclick");
				
			} 
			if (datas[i].menu_type == "历史统计" && hasHistory == false) {
				$("#history>a").attr("href", datas[i].menu_url);
				hasHistory = true;
				$("#history>a").removeAttr("onclick");
				
			} 
		}
	});*/
});
app.config(function($stateProvider, $urlRouterProvider, $ocLazyLoadProvider) {
	
	$stateProvider.state('department',{
		url : '/department',
		templateUrl : 'jsp/web/department/departmentList.jsp',
		controller : 'departmentController',
		resolve : {
			deps : ["$ocLazyLoad",function($ocLazyLoad){
				return $ocLazyLoad.load(["js/web/department/departmentList.js"]);
			}]
		}
	}).state('departmentAdd',{
		url : '/departmentAdd',
		templateUrl : 'jsp/web/department/departmentAdd.jsp'
//		controller : 'departmentAddController',
//		resolves : {
//			deps : ["$ocLazyLoad",function($ocLazyLoad){
//				return $ocLazyLoad.load(["js/web/department/departmentAdd.js"]);
//			}]
//		}
	}).state('user',{
		url : '/user',
		templateUrl : 'jsp/web/user/userList.jsp',
		controller : 'userController',
		resolve : {
			deps : ["$ocLazyLoad",function($ocLazyLoad){
				return $ocLazyLoad.load(["js/web/user/userList.js"]);
			}]
		}
	}).state('userAdd',{
		url : '/userAdd',
		templateUrl : 'jsp/web/user/userAdd.jsp'
	}).state('equipmentType',{
		url : '/equipmentType',
		templateUrl : 'jsp/web/equipmentType/equipmentTypeList.jsp',
		controller : 'equipmentTypeAddController',
		resolve : {
			deps : ["$ocLazyLoad",function($ocLazyLoad){
				return $ocLazyLoad.load(["js/web/equipmentType/equipmentTypeList.js"]);
			}]
		}
	}).state('equipmentTypeAdd',{
		url : '/equipmentTypeAdd',
		templateUrl : 'jsp/web/equipmentType/equipmentTypeAdd.jsp'
	}).state('equipment',{
		url : '/equipment',
		templateUrl : 'jsp/web/equipment/equipmentList.jsp',
		controller : 'equipmentContorller',
		resolve : {
			deps : ["$ocLazyLoad",function($ocLazyLoad){
				return $ocLazyLoad.load(["js/web/equipment/equipmentList.js"]);
			}]
		}
	}).state('equipmentAdd',{
		url : '/equipmentAdd',
		templateUrl : 'jsp/web/equipment/equipmentAdd.jsp'
	})
/*	$stateProvider.state('monitor', {
		url : '/monitor',
		templateUrl : 'jsp/web/monitor.jsp',
		controller : "monitorController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/monitorController.js" ]);
			} ]
		}
	}).state('forecast', {
		url : '/forecast',
		templateUrl : 'jsp/web/forecast.jsp',
		controller : "forecastController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/forecastController.js" ]);
			} ]
		}
	}).state('system', {
		url : '/system',
		templateUrl : 'jsp/web/system.jsp',
		controller : function($http) {
			$http.post(
					'autihority/queryUserPermissions?groupId=' + $("#groupId").val(),
					{}).success(function(result) {
				var datas = result.dataList;
				for (var i = 0; i < datas.length; i++) {
					if (datas[i].menu_type == "系统管理") {
						$("#"+datas[i].menu_code+">a").attr("href", datas[i].menu_url);
						$("#"+datas[i].menu_code+">a").removeAttr("onclick");
					} 
				}
			});
			resetPageHeight();
			$(".m_nav_list>li").removeClass("current");
			$("#system").addClass("current");
		}
	}).state('history', {
		url : '/history',
		templateUrl : 'jsp/web/history.jsp',
		controller : function($http) {
			$http.post(
					'autihority/queryUserPermissions?groupId=' + $("#groupId").val(),
					{}).success(function(result) {
				var datas = result.dataList;
				for (var i = 0; i < datas.length; i++) {
					if (datas[i].menu_type == "历史统计") {
						$("#"+datas[i].menu_code+">a").attr("href", datas[i].menu_url);
						$("#"+datas[i].menu_code+">a").removeAttr("onclick");
					} 
				}
			});
			resetPageHeight();
			$(".m_nav_list>li").removeClass("current");
			$("#history").addClass("current");
		}
	}).state('history.warn', {
		url : '/warningInfo',
		templateUrl : 'jsp/web/warn.jsp',
		controller : "warningInfoController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/warn.js" ]);
			} ]
		}

	}).state('history.alarm', {
		url : '/alarm',
		templateUrl : 'jsp/web/alarm.jsp',
		controller : "alarmController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/countAlarm.js" ]);
			} ]
		}
	}).state('system.userInfo', {
		url : '/userInfo',
		templateUrl : 'jsp/web/userInfo.jsp',
		controller : "userInfoController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/user_info.js" ]);
			} ]
		}
	}).state('system.userInfoAdd', {
		url : '/userInfoAdd',
		templateUrl : 'jsp/web/userInfoAdd.jsp',
		controller : "userInfoAddController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/user_infoAdd.js" ]);
			} ]
		}
	}).state('system.userInfoUpdate', {
		url : '/userInfoUpdate/{id}',
		templateUrl : 'jsp/web/userInfoUpdate.jsp',
		controller : 'userInfoUpdateController',
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/user_infoUpdate.js" ]);
			} ]
		}
	}).state('system.userGroup', {
		url : '/userGroup',
		templateUrl : 'jsp/web/userGroup.jsp',
		controller : "userGroupController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/user_group.js" ]);
			} ]
		}
	}).state('system.userGroupUpdate', {
		url : '/userGroupUpdate/{id}',
		templateUrl : 'jsp/web/userGroupUpdate.jsp',
		controller : 'userGroupUpdateController',
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/user_groupUpdate.js" ]);
			} ]
		}
	}).state('system.userGroupAdd', {
		url : '/userGroupAdd',
		templateUrl : 'jsp/web/userGroupAdd.jsp',
		controller : "userGroupAddController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/user_groupAdd.js" ]);
			} ]
		}
	}).state('system.authority', {
		url : '/auathority',
		templateUrl : 'jsp/web/authority.jsp',
		controller : "authorityController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/authority.js" ]);
			} ]
		}
	}).state('system.authorityAdd', {
		url : '/authorityAdd',
		templateUrl : 'jsp/web/authorityAdd.jsp',
		controller : "authorityAddController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/authorityAdd.js" ]);
			} ]
		}
	}).state('system.authorityUpdate', {
		url : '/authorityUpdate/{groupId}',
		templateUrl : 'jsp/web/authorityUpdate.jsp',
		controller : "authorityUpdateController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/authorityUpdate.js" ]);
			} ]
		}
	}).state('system.alarmRules', {
		url : '/alarmRules',
		templateUrl : 'jsp/web/alarmRules.jsp',
		controller : "alarmRulesController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/alarmRules.js" ]);
			} ]
		}
	}).state('system.alarmRulesAdd', {
		url : '/alarmRulesAdd',
		templateUrl : 'jsp/web/alarmRulesAdd.jsp',
		controller : "alarmRulesAddController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/alarmRulesAdd.js"]);
			} ]
		}
	}).state('system.alarmRulesUpdate', {
		url : '/alarmRulesUpdate/{id}',
		templateUrl : 'jsp/web/alarmRulesUpdate.jsp',
		controller : "alarmRulesUpdateController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/alarmRulesUpdate.js" ]);
			} ]
		}
	}).state('system.warningRule', {
		url : '/warningRule',
		templateUrl : 'jsp/web/warningRules.jsp',
		controller : "warningRulesController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/warningRules.js" ]);
			} ]
		}
	}).state('system.warningRulesUpdate', {
		url : '/warningRulesUpdate/{id}',
		templateUrl : 'jsp/web/warningRulesUpdate.jsp',
		controller : "warningRulesUpdateController",
		resolve : {
			deps : [ "$ocLazyLoad", function($ocLazyLoad) {
				return $ocLazyLoad.load([ "js/web/warningRulesUpdate.js" ]);
			} ]
		}
	});*/
});
